<?php
Class Boodschapschrift_model extends CI_Model
{
	public function getBoodschapschrift($id)
	{	
		$this->db->select('*');
		$this->db->from('client');
		$this->db->join('boodschapschrift', 'client.client_id = boodschapschrift.client_id', 'inner');
		$this->db->where('client.client_id', $id);
		
		$query = $this->db->get();
		
		return $query->result();
	}
	public function getBoodschapschriftById($id)
	{	
		$this->db->where('boodschapschrift_id', $id);
		$query = $this->db->get('boodschapschrift');
		return $query->result();
	}
	
	public function newBoodschapschrift()
	{
		$tijd = $this->input->post('uur').':'.$this->input->post('minuten').'0:00';
		
		$data = array(
			'datum' => $this->input->post('datum'),
			'tijd' => $tijd,
			'bericht' => $this->input->post('bericht'),
			'onderwerp' => $this->input->post('onderwerp'),
			'client_id' => $this->uri->segment(4)
		);
		
		$query = $this->db->insert('boodschapschrift', $data);
	}
	
	public function updateBoodschapschrift($id)
	{
		$tijd = $this->input->post('uur').':'.$this->input->post('minuten').'0:00';
		$bdData = array(			
			//'boodschapschrift_id' => $this->input->post('boodschapschrift_id'),
			'datum' => $this->input->post('datum'),
			'tijd' => $tijd,
			'bericht' => $this->input->post('bericht'),
			'onderwerp' => $this->input->post('onderwerp'),
			'client_id' => $this->uri->segment(6)
		);
		
		$this->db->where('boodschapschrift_id', $id);
		$query = $this->db->update('boodschapschrift', $bdData);
	}
	
	public function deleteBoodschapschrift($id)
	{
		$this->db->where('boodschapschrift_id', $id);
		$query = $this->db->delete('boodschapschrift');
	}
}
?>